﻿using System.Xml.Serialization;
using Microsoft.SharePoint;

namespace SecurityParser
{
    public class RoleMapping : DeployableItem
    {
        [XmlAttribute("name")]
        public string Name
        {
            get;
            set;
        }

        internal void Apply(SPRoleAssignment newAssignment, SPWeb web)
        {
            //if this item shoudl be deployed
            if (this.ShouldDeploy())
            {
                //find the role definition
                SPRoleDefinition roleDefinition = web.RoleDefinitions[Name];

                //attach it to our assignment
                newAssignment.RoleDefinitionBindings.Add(roleDefinition);
            }
        }
    }
}
